import java.util.Stack;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-04-12
 * Time:11:42
 */
public class Text3 {
    public int evalRPN(String[] tokens) {
        Stack<Integer> fw=new Stack<>();
        for(String s:tokens)
        {
            if(isOpera(s))
            {
                fw.push(Integer.parseInt(s));
            }
            else {
                int num1=fw.pop(), num2=fw.pop();
                switch(s){
                    case "+": fw.push(num2+num1);break;
                    case "-": fw.push(num2-num1);break;
                    case "/": fw.push(num2/num1);break;
                    case "*": fw.push(num2*num1);break;}

            }
        }
        return fw.pop();
    }

    public boolean isOpera(String sum)
    {
        if(sum.equals("+")||sum.equals("-")||sum.equals("/")||sum.equals("*"))
        {
            return false;
        }
        else return true;
    }
    public static void main(String[] args) {
        Text3 fw=new Text3();
        String[] kk={"2","1","+","3","*"};
        System.out.println(fw.evalRPN(kk));
    }
}
